<template>
  <auth-object-template :auth-object="authObject2"
               :list-role="listRole"
               :list-user="listUser"
               :list-dept="listDept"
               :list-position="listPosition"
               :is-disabled="isDisabled"
               :title="title"
  ></auth-object-template>
</template>

<script>

import AuthObjectTemplate from "./AuthObjectTemplate.vue";
import {listRole} from "@/api/organization/role";
import {listUser} from "@/api/organization/user";
import {listDept} from "@/api/organization/dept";

export default {
  name: 'AuthObject',
  components: {
    AuthObjectTemplate
  },
  props: {
    title:String,
    authObject: {
      type: Object,
      required: true,
      default() {
        return {
          roles: [],
          depts: [],
          users: [],
          positions: [],
        }
      }
    },
    isDisabled:{
      type:Boolean,
      default() {
        return false;
      }
    },
  },
  computed:{
    authObject2:{
      get(){
        //console.log("authObject的值为",this.authObject)
        return this.authObject
      },
      set(newVal){
        console.log("authObject重新赋值",newVal)
        return this.$emit('update:authObject',newVal)
      }
    }
  },
  methods: {
    listRole(){
      return listRole()
    },
    listUser(){
      return listUser()
    },
    listDept(){
      return listDept()
    },
    //todo 岗位还没有完成
    listPosition(){
      this.$message.info("岗位暂时没有开放")
      return Promise.reject("岗位暂时没有开放")
    },
  }
}
</script>


<style scoped lang="scss">

</style>